// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import store from 'store/store.js'
Vue.config.productionTip = false

App.mpType = 'app'
// 跟路径

import {
	$http
} from '@escook/request-miniprogram'

$http.baseUrl = 'http://jxk.zjxyq.com:30752/app-api/' // 环境 
uni.$http = $http
// 请求拦截
$http.beforeRequest = (options) => {
	// console.log(options.data, '这是接口的参数')

	if (options.url.split('/').indexOf('nl') !== -1) {
		return
		// console.log('这个接口不需要登录')
	} else {
		options.header.access_token = store.state.m_cart.token
		// console.log('这个接口需要登录')
	}

}


// 响应拦截
$http.afterRequest = (options) => {
	// console.log(options.data, '这是你接口的返回值')
	uni.hideLoading()
	if (options.data.code !== 200 && options.data.code !== 201 && options.data.code !== 1004) {
		uni.showToast({
			title: options.data.msg,
			icon: 'none',
			duration: 2000
		})
	}
}
const app = new Vue({
	...App,
	store
})
app.$mount()
// 错误提示
uni.$showMsg = (title = '数据加载失败', duration = 1500) => {
	uni.showToast({
		title,
		duration,
		icon: 'none'
	})
}
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import App from './App.vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif